#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;
using i64=long long;
//1.integer overflow (1e5 * 1e5) (2e9 + 2e9)
//2.runtime error
//3.boundary condition
int dx[] = {0, -1, 0, 0, 1};
int dy[] = {0, 0, -1, 1, 0};
void solve()
{
    int n,m;
    cin >> n >> m;
    vector grid(n + 2, vector<char>(m + 2));
    for(int i = 1; i <= n; i++)
    {
    	for(int j = 1; j <= m; j++)
    	{
    		cin >> grid[i][j];
    	}
    }
    vector bad(n + 2, vector(m + 2, 0));
    auto check = [&](int x, int y) -> bool
    {
    	if(x >= 1 && x <= n && y >= 1 && y <= m)
    	{
    		return true;
    	}
    	return false;
    };
    for(int i = 1; i <= n; i++)
    {
    	for(int j = 1; j <= m; j++)
    	{
    		if(grid[i][j] == '#')
    		{
    			for(int k = 1; k <= 4 ; k++)
    			{
    				int nx = i + dx[k];
    				int ny = j + dy[k];
    				if(check(nx, ny))
    				{
    					bad[nx][ny] = 1;
    				}
    			}
    		}
    	}
    }
    int ans = 0;
    vector vis(n + 2,vector<int>(m + 2, -1));
    for(int i = 1; i <= n; i++)
    {
    	for(int j = 1; j <= m; j++)
    	{
    		if(grid[i][j] == '.' && vis[i][j] == -1)
    		{
    			int res = 0;
    			queue<pair<int,int>> q;
    			vis[i][j] = i * n + j;
    			q.emplace(i, j);
    			while(!q.empty())
    			{
    				auto [x, y] = q.front();
    				q.pop();
    				res++;
    				if(bad[x][y])
    				{
    					continue;
    				}
    				for(int k = 1; k <= 4; k++)
    				{
    					int nx = x + dx[k];
    					int ny = y + dy[k];
    					if(check(nx, ny) && vis[nx][ny] != i * n + j)
    					{
    						vis[nx][ny] = i * n + j;
    						q.emplace(nx, ny);
    					}
    				}
    			}
    			ans = max(ans, res);
    		}
    	}
    }
    cout << ans;
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(10);
    cout<<fixed;
    int t=1;
    //cin>>t;
    while(t--)
    {
        solve();
    }
#ifdef LOCAL_DEFINE
    freopen("input.txt", "r", stdin);
#endif
    
#ifdef LOCAL_DEFINE
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
    return 0;
}
